package com.liunian.subject.infra.basic.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liunian.subject.common.enums.IsDeletedFlagEnum;
import com.liunian.subject.infra.basic.entity.SubjectBrief;
import com.liunian.subject.infra.basic.mapper.SubjectBriefMapper;
import com.liunian.subject.infra.basic.service.SubjectBriefService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class SubjectBriefServiceImpl extends ServiceImpl<SubjectBriefMapper, SubjectBrief> implements SubjectBriefService {

    @Resource
    private SubjectBriefMapper subjectBriefMapper;

    @Override
    public SubjectBrief queryAnswerById(long subjectId) {
        LambdaQueryWrapper<SubjectBrief> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SubjectBrief::getSubjectId, subjectId)
                .eq(SubjectBrief::getIsDeleted, IsDeletedFlagEnum.UN_DELETED.getCode());
        // todo: 可能出现一个简答题多个回答，所以暂时我们只取查到的第一个
        return subjectBriefMapper.selectList(wrapper).get(0);
    }
}
